package concept.misc;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

import concept.misc.Enum.names;

class Enum
{
	enum names
	{
		GOOD,BETTER,BEST
	}
	
}

class Item
{
	String value;
	Item(String value)
	{
		this.value = value;
	}
}


public class EnumLab
{
	static void doUpdateEnumValueAtRuntime()
	{
		for (Enum.names name:Enum.names.values())
		{
			System.out.println(StringUtils.capitalize(name.toString().toLowerCase()));
		}
		
		Map<names,Item> map = new HashMap<Enum.names, Item>();
		map.put(Enum.names.GOOD, new Item("good"));
		map.put(Enum.names.BETTER, new Item("better"));
		map.put(Enum.names.BEST, new Item("best"));
		
		map.get(Enum.names.BETTER).value = "Better but not enough!";
		
		System.out.println(map.get(Enum.names.BETTER).value);
	}
	static void doEnumComparison()
	{
		names name = names.valueOf("GOOD");
		try
		{
			assert(name!=names.GOOD):"enum valued ["+names.GOOD+"] equals enum valued ["+names.GOOD+"]";
		}
		catch(AssertionError e)
		{
			System.err.println(e.getMessage());
			try
			{
				assert(name==names.BEST):"enum valued ["+names.GOOD+"] doesn't equal enum valued ["+names.BEST+"]";
			}
			catch(AssertionError ae)
			{
				System.err.println(ae.getMessage());
			}
		}
	}
	public static void main(String[] args)
	{
		//doUpdateEnumValueAtRuntime();
		doEnumComparison();
	}
}
